﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using NParameterizedTestTests.ObjectBuilders;
using System;

namespace NParameterizedTestTests.TestCollectionTests
{
    [TestClass]
    public class Evaluation_exception_handling_tests
    {
        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void If_an_exception_is_thrown_in_setup_the_test_case_is_failed()
        {
            var collection = new TestCollectionBuilder()
                .WithSetup(() => { throw new IndexOutOfRangeException("Oups"); })
                .WithTestCase()
                .Build();

            collection.Evaluate();
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void If_an_exception_is_thrown_in_the_method_under_test_the_test_case_is_failed()
        {
            var collection = new TestCollectionBuilder()      
                .WithMethodUnderTest((a, b) => { throw new IndexOutOfRangeException("Oups"); })                          
                .WithTestCase()
                .Build();

            collection.Evaluate();
        }
    }
}
